<template>
  <div>
    <h1>日志管理(⁎⁍̴̛ᴗ⁍̴̛⁎)</h1><hr>
    <div style="margin-top: 20px;padding-right: 1090px">
      <el-button
          size="mini"
          type="danger"
          @click="toggleSelection()">取消</el-button>
      <el-button
          size="mini"
          type="danger"
          @click="del()">删除</el-button>
    </div>
    <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange">
      <el-table-column
          type="selection"
          width="55">
      </el-table-column>
      <el-table-column
          label="日期"
          width="180">
        <template slot-scope="scope">{{ scope.row.createTime }}</template>
      </el-table-column>
      <el-table-column
          prop="ip"
          label="操作地址"
          width="180">
      </el-table-column>
      <el-table-column
          prop="accessName"
          label="访问方法"
          width="180"
          show-overflow-tooltip>
      </el-table-column>
      <el-table-column
          prop="accessType"
          label="访问类型"
          width="180"
          show-overflow-tooltip>
      </el-table-column>
      <el-table-column
          prop="accessUrl"
          label="访问地址"
          width="180"
          show-overflow-tooltip>
      </el-table-column>
    </el-table>

  </div>
</template>

<script>
export default {
  name: "LogsView",
  data(){
    return{
      tableData:[],
      ids:[]
    }
  },methods:{
    /*日志列表*/
    sysLogsList(){
      this.axios.post("http://172.20.10.5:8003/api/sys-logs/sysLogList").then(res=>{
        this.tableData=res.data;
      })
    },
    toggleSelection(rows) {
      if (!rows) {
        this.$refs.multipleTable.clearSelection();
        this.ids=[]
      }
    },
    handleSelectionChange(val) {
      this.ids=[]
      this.multipleSelection = val;
      if(val){
        val.forEach(item=>{
          this.ids=this.ids+","+item.id
        })
        this.ids=this.ids.substring(1,this.ids.length)
      }
    },del(){
      //alert(this.ids)
      console.log(this.ids)
      this.axios.post("http://172.20.10.5:8003/api/sys-logs/delLogs?ids="+this.ids).then(res=>{
        if(res.data=='success'){
          this.$message.success("删除成功！！");
          this.sysLogsList();
        }
      })
    }
  },created() {
    this.sysLogsList()
  }
}
</script>

<style scoped>

</style>